From e014efcab228812ef0751e4706d648c19add1ab1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 11 Sep 2025 13:29:31 +0200 Subject: [PATCH] build: Define test dependencies Ideally meson tests should just work without any pre-requisite build, instead, we only need a configured build folder to work, but this does not go as expected in gnome shell at the moment. Since tests require generated files and compiled typelibs they don't depend on, so just using `meson test -C build ` does not work as expected. So add test dependencies on test cases. We do not need to have per-test dependencies right now since most of them share just the same requirements, and this makes it easier to maintain Part-of: --- data/meson.build | 7 ++++--- src/meson.build | 4 ++-- src/st/meson.build | 1 + tests/meson.build | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/data/meson.build b/data/meson.build index d48308743..cc7b5e2a1 100644 --- a/data/meson.build +++ b/data/meson.build @@ -59,11 +59,12 @@ data_resources = [ {'name': 'osk-layouts'}, {'name': 'theme', 'deps': theme_deps} ] +data_resources_targets = [] foreach resource : data_resources name = resource.get('name') deps = resource.get('deps', []) - gnome.compile_resources( + data_resources_targets += gnome.compile_resources( 'gnome-shell-' + name, 'gnome-shell-@0@.gresource.xml'.format(name), source_dir: name, @@ -150,8 +151,8 @@ if have_systemd endif # for unit tests - gnome.compile_schemas() only looks in srcdir -custom_target('compile-schemas', +compiled_schemas = custom_target('compile-schemas', input: schema, output: 'gschemas.compiled', command: [find_program('glib-compile-schemas'), '--strict', data_builddir], - build_by_default: true) +) diff --git a/src/meson.build b/src/meson.build index b729ec03a..a4ce889ea 100644 --- a/src/meson.build +++ b/src/meson.build @@ -282,7 +282,7 @@ libshell_gir = gnome.generate_gir(libshell, kwargs: introspection_common, ) -executable('gnome-shell', 'main.c', +gnome_shell_binary = executable('gnome-shell', 'main.c', c_args: gnome_shell_cflags + typelib_cflags, dependencies: gnome_shell_deps + [libshell_dep, libst_dep, mutter_dep], include_directories: [conf_inc], @@ -302,7 +302,7 @@ if have_portal_helper ) endif -executable('gnome-shell-perf-helper', 'shell-perf-helper.c', js_resources, +gnome_shell_perf_helper = executable('gnome-shell-perf-helper', 'shell-perf-helper.c', js_resources, dependencies: [gtk_dep, gio_dep, m_dep], include_directories: [conf_inc], install_dir: libexecdir, diff --git a/src/st/meson.build b/src/st/meson.build index 5fb742b25..693a143f4 100644 --- a/src/st/meson.build +++ b/src/st/meson.build @@ -225,6 +225,7 @@ if get_option('tests') and have_x11_client test('css-styling', test_theme, suite: 'st', + depends: compiled_schemas, workdir: meson.current_source_dir(), ) endif diff --git a/tests/meson.build b/tests/meson.build index 6882e44bc..806a0c7ad 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -13,6 +13,15 @@ gvc_typelib_path = fs.parent(libgvc.get_variable('libgvc_gir')[1].full_path()) shell_typelib_path = fs.parent(libshell_gir[1].full_path()) st_typelib_path = fs.parent(libst_gir[1].full_path()) +# Shared tests dependencies. +tests_dependencies = [ + compiled_schemas, + data_resources_targets, + libst_gir[1], + libshell_gir[1], + libgvc_gir[1], +] + unit_testenv = environment() unit_testenv.set('GNOME_SHELL_DATADIR', data_builddir) unit_testenv.append('GI_TYPELIB_PATH', gvc_typelib_path, separator: ':') @@ -59,6 +68,7 @@ foreach test, extra_args : unit_tests 'unit/@0@.js'.format(test), ], suite: 'unit', + depends: tests_dependencies, env: local_test_env, protocol: 'tap', workdir: meson.current_source_dir()) @@ -106,6 +116,11 @@ foreach shell_test : shell_tests options, '@0@/shell/@1@.js'.format(meson.current_source_dir(), test_name), ], + depends: [ + gnome_shell_binary, + gnome_shell_perf_helper, + tests_dependencies, + ], is_parallel: false, env: shell_testenv, ) -- 2.39.5